package com.mvp.base

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import com.blankj.utilcode.util.ToastUtils
import com.mvp.mvpdemo.BuildConfig
import com.umeng.analytics.MobclickAgent


/**
 * Created By Mahongyin
 * Date    2020/10/15 16:18
 *
 */
abstract class BaseActivity : AppCompatActivity() {

    private val TAG = javaClass.name

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())
        initCreate()
        initData()
    }

    @LayoutRes
    protected abstract fun getLayoutId(): Int

    protected abstract fun initCreate()
    protected abstract fun initData()


    override fun onResume() {
        super.onResume()
        //友盟统计
        MobclickAgent.onResume(this)
    }

    override fun onPause() {
        super.onPause()
        MobclickAgent.onPause(this)
    }


    protected fun log(logMessage: String) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, logMessage)
        }
    }

    //activity跳转
    protected fun <T : Activity> goActivity(intentClass: Class<T>) {
        val intent = Intent()
        intent.setClass(this, intentClass)
        startActivity(intent)
    }
}